package com.ruoyi.system.V2.gameAttr.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.exception.GlobalException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.UUIDGenerator;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttrTemplateMapper;
import com.ruoyi.system.V2.gameAttr.mapper.GameAttributeMapper;
import com.ruoyi.system.V2.gameAttr.service.IGameAttrTemplateService;
import com.ruoyi.system.V2.gameAttr.service.IGameAttributeService;
import com.ruoyi.system.V2.gameInfo.mapper.GameInfoMapper;
import com.ruoyi.system.interAttr.domain.*;
import com.ruoyi.system.interAttr.mapper.InterAttrMapper;
import com.ruoyi.system.interAttr.service.InterGetAttr;
import com.ruoyi.system.model.domain.GameAttrTemplate;
import com.ruoyi.system.model.domain.GameAttribute;
import com.ruoyi.system.model.domain.GameInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;


/**
 * 游戏自定义属性对应模板Service业务层处理
 *
 * @author ruoyi
 * @date 2023-04-04
 */
@Service
public class GameAttrTemplateServiceImpl implements IGameAttrTemplateService {
    @Autowired
    private GameAttrTemplateMapper gameAttrTemplateMapper;
    @Autowired
    private GameAttributeMapper gameAttributeMapper;
    @Autowired
    private IGameAttributeService gameAttributeService;
    @Resource
    InterAttrMapper interAttrMapper;
    @Autowired
    InterGetAttr interGetAttr;
    @Autowired
    GameInfoMapper gameInfoMapper;

    /**
     * 查询游戏自定义属性对应模板
     *
     * @param id 游戏自定义属性对应模板主键
     * @return 游戏自定义属性对应模板
     */
    @Override
    public GameAttrTemplate selectGameAttrTemplateById(Long id) {
        return gameAttrTemplateMapper.selectGameAttrTemplateById(id);
    }

    /**
     * 查询游戏自定义属性对应模板列表
     *
     * @param gameAttrTemplate 游戏自定义属性对应模板
     * @return 游戏自定义属性对应模板
     */
    @Override
    public List<GameAttrTemplate> selectGameAttrTemplateList(GameAttrTemplate gameAttrTemplate) {
        List<GameAttrTemplate> gameAttrTemplates = gameAttrTemplateMapper.selectGameAttrTemplateList(gameAttrTemplate);
        if (CollectionUtils.isNotEmpty(gameAttrTemplates)) {
            GameAttribute gameAttribute = new GameAttribute();
            GameAttribute gameAttributeReq = new GameAttribute();
            for (GameAttrTemplate attrTemplate : gameAttrTemplates) {
                if (attrTemplate.getAttributeId() != null && attrTemplate.getAttributeId() != 0) {
                    if (attrTemplate.getFieldType().equals("boxradio")) {
                        GameAttribute gameAttributep =
                                gameAttributeMapper.selectGameAttributeById(attrTemplate.getAttributeId());
                        gameAttributeReq.setGameId(gameAttributep.getGameId());
                        gameAttributeReq.setParentId(gameAttributep.getParentId());
                        gameAttributeReq.setAcode(gameAttributep.getAcode());
                        List<GameAttribute> gameAttributes = gameAttributeService.listAllTree(gameAttributeReq);
                        if (CollectionUtils.isNotEmpty(gameAttributes)) {
                            GameAttribute gameAttribute1 = gameAttributes.get(0);
                            List<GameAttribute> childAttributes1 = gameAttribute1.getChildGameAttributes();

                            if (Objects.nonNull(childAttributes1)){
                                for (GameAttribute childAttribute : childAttributes1) {
                                    List<GameAttribute> childAttributes = childAttribute.getChildAttributes();
                                    childAttribute.setChildGameAttributes(childAttributes);
                                }

                            }

                            attrTemplate.setChildAttributes(childAttributes1);

                        }
                    } else {
                        gameAttribute.setParentId(attrTemplate.getAttributeId());
                        List<GameAttribute> gameAttributes = gameAttributeMapper.selectGameAttributeList(gameAttribute);
                        if (CollectionUtils.isNotEmpty(gameAttributes)) {
                            attrTemplate.setChildAttributes(gameAttributes);
                        }
                    }
                }
            }
        }
        return gameAttrTemplates;
    }

    /**
     * 新增游戏自定义属性对应模板
     *
     * @param gameAttrTemplate 游戏自定义属性对应模板
     * @return 结果
     */
    @Override
    public int insertGameAttrTemplate(GameAttrTemplate gameAttrTemplate) {
        gameAttrTemplate.setCreateTime(DateUtils.getNowDate());
        return gameAttrTemplateMapper.insertGameAttrTemplate(gameAttrTemplate);
    }

    /**
     * 修改游戏自定义属性对应模板
     *
     * @param gameAttrTemplate 游戏自定义属性对应模板
     * @return 结果
     */
    @Override
    public int updateGameAttrTemplate(GameAttrTemplate gameAttrTemplate) {
        gameAttrTemplate.setUpdateTime(DateUtils.getNowDate());
        return gameAttrTemplateMapper.updateGameAttrTemplate(gameAttrTemplate);
    }

    /**
     * 批量删除游戏自定义属性对应模板
     *
     * @param ids 需要删除的游戏自定义属性对应模板主键
     * @return 结果
     */
    @Override
    public int deleteGameAttrTemplateByIds(Long[] ids) {
        return gameAttrTemplateMapper.deleteGameAttrTemplateByIds(ids);
    }

    /**
     * 删除游戏自定义属性对应模板信息
     *
     * @param id 游戏自定义属性对应模板主键
     * @return 结果
     */
    @Override
    public int deleteGameAttrTemplateById(Long id) {
        return gameAttrTemplateMapper.deleteGameAttrTemplateById(id);
    }

    @Override
    public List<GameAttrTemplate> selectGameAttrTemplateByGameIdAndAuto(Long gameId, List<String> auto) {
        return gameAttrTemplateMapper.selectGameAttrTemplateByGameIdAndAuto(gameId, auto);
    }

    @Override
    public List<GameAttrTemplate> selectGameAttrTemplateByGameId(Long gameId) {
        return gameAttrTemplateMapper.selectGameAttrTemplateByGameId(gameId);
    }

    @Override
    public List<GameAttrTemplate> yuduAttr(Long gameId, String type) {

        GameAttrTemplate gameAttrTemplate = new GameAttrTemplate();
        gameAttrTemplate.setGameId(gameId);
        gameAttrTemplate.setIsEnable("0");
        List<String> types = new ArrayList<>();
        if (Objects.equals("1", type)) {
            types.add("radio");
            gameAttrTemplate.setFieldTypes(types);
        } else if (Objects.equals("2", type)) {

            types.add("checkbox");
            types.add("boxradio");
            gameAttrTemplate.setFieldTypes(types);
        } else if (Objects.equals("3", type)) {
            types.add("number");
            types.add("input");
            gameAttrTemplate.setFieldTypes(types);
        }
        GameAttribute gameAttributeReq = new GameAttribute();

        List<GameAttrTemplate> gameAttrTemplates = gameAttrTemplateMapper.selectGameAttrTemplateList(gameAttrTemplate);
        if (CollectionUtils.isNotEmpty(gameAttrTemplates)) {
            for (GameAttrTemplate attrTemplate : gameAttrTemplates) {
                if (attrTemplate.getAttributeId() != null && attrTemplate.getAttributeId() != 0) {


                    if (attrTemplate.getFieldType().equals("boxradio")) {
                        GameAttribute gameAttributep =
                                gameAttributeMapper.selectGameAttributeById(attrTemplate.getAttributeId());
                        gameAttributeReq.setGameId(gameAttributep.getGameId());
                        gameAttributeReq.setParentId(gameAttributep.getParentId());
                        gameAttributeReq.setAcode(gameAttributep.getAcode());
                        List<GameAttribute> gameAttributes = gameAttributeService.listAllTree(gameAttributeReq);
                        if (CollectionUtils.isNotEmpty(gameAttributes)) {
                            attrTemplate.setChildAttributes(gameAttributes.get(0).getChildGameAttributes());
                        }
                    } else {
                        gameAttributeReq.setGameId(gameId);
                        gameAttributeReq.setParentId(attrTemplate.getAttributeId());
                        List<GameAttribute> gameAttributes = gameAttributeService.listAllTree(gameAttributeReq);
                        if (CollectionUtils.isNotEmpty(gameAttributes)) {
                            attrTemplate.setChildAttributes(gameAttributes);
                        }
                    }
                }
            }
            return gameAttrTemplates;
        }
        return null;
    }

    @Override
    public List<GameAttribute> yuduCheckAttr(Long gameId, String type) {
        List<GameAttribute> yuduCheckAttr = new ArrayList<>();
        GameAttrTemplate gameAttrTemplate = new GameAttrTemplate();
        gameAttrTemplate.setGameId(gameId);
        gameAttrTemplate.setIsEnable("0");
        List<String> types = new ArrayList<>();
        types.add("checkbox");
        types.add("boxradio");
        gameAttrTemplate.setFieldTypes(types);

        GameAttribute gameAttributeReq = new GameAttribute();

        List<GameAttrTemplate> gameAttrTemplates = gameAttrTemplateMapper.selectGameAttrTemplateList(gameAttrTemplate);
        if (CollectionUtils.isNotEmpty(gameAttrTemplates)) {
            for (GameAttrTemplate attrTemplate : gameAttrTemplates) {
                if (attrTemplate.getAttributeId() != null && attrTemplate.getAttributeId() != 0) {
                    if (attrTemplate.getFieldType().equals("boxradio")) {
                        GameAttribute gameAttributep =
                                gameAttributeMapper.selectGameAttributeById(attrTemplate.getAttributeId());
                        gameAttributeReq.setGameId(gameAttributep.getGameId());
                        gameAttributeReq.setParentId(gameAttributep.getParentId());
                        gameAttributeReq.setAcode(gameAttributep.getAcode());
                        List<GameAttribute> gameAttributes = gameAttributeService.listAllTree(gameAttributeReq);
                        if (CollectionUtils.isNotEmpty(gameAttributes)) {
                            attrTemplate.setChildAttributes(gameAttributes.get(0).getChildGameAttributes());
                        }
                    } else {
                        gameAttributeReq.setGameId(gameId);
                        gameAttributeReq.setParentId(attrTemplate.getAttributeId());
                        List<GameAttribute> gameAttributes = gameAttributeService.listAllTree(gameAttributeReq);
                        if (CollectionUtils.isNotEmpty(gameAttributes)) {
                            attrTemplate.setChildAttributes(gameAttributes);
                        }
                    }
                }
            }
            for (GameAttrTemplate attrTemplate : gameAttrTemplates) {
                if (CollectionUtils.isNotEmpty(attrTemplate.getChildAttributes())){
                    List<GameAttribute> childAttributes = attrTemplate.getChildAttributes();
                    for (GameAttribute childAttribute : childAttributes) {
                        if (CollectionUtils.isNotEmpty(childAttribute.getChildGameAttributes())){
                            List<GameAttribute> childGameAttributes = childAttribute.getChildGameAttributes();
                            for (GameAttribute childGameAttribute : childGameAttributes) {
                                yuduCheckAttr.add(childGameAttribute);
                            }
                        }else{
                            yuduCheckAttr.add(childAttribute);
                        }
                    }
                }

            }
        }
        return yuduCheckAttr;
    }

    @Override
    public List<InterAttrRes> interAttr(String gameId, String type, String config) {

        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }

        //type 1 单选  2 多选 3 输入框
        return interGetAttr.getAttr(gameId, type, config);
    }

    @Override
    public List<InterAttrRes> interCheckAttr(String gameId, String type, String config) {

        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }

        //type 1 单选  2 多选 3 输入框
        return interGetAttr.getCheckAttr(gameId, type, config);
    }
    @Override
    public List<GamesRes> interGame(String config) {
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        return interGetAttr.getGames(config);
    }

    @Override
    public List<InterServerRes> interServers(String config, String gameId) {
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        return interGetAttr.getServers(config, gameId);
    }

    @Override
    public List<GameAttribute> yuduServe(Long gameId) {


//        List<JSONObject> result = new ArrayList<>();


        GameInfo gameInfo = gameInfoMapper.selectGameInfoById(gameId);
        if (gameInfo.getType() == 0) {
            GameAttribute gameAttribute = new GameAttribute();
            gameAttribute.setGameId(gameId);
            gameAttribute.setSystemKey("system");

            List<GameAttribute> list = gameAttributeService.keySelectGameAttributeList(gameAttribute);
            for (GameAttribute attribute : list) {
                gameAttribute.setSystemKey("carrier");
                attribute.setUuid(UUIDGenerator.generateUuid6());
                List<GameAttribute> list1 = gameAttributeService.keySelectGameAttributeList(gameAttribute);
                attribute.setChildGameAttributes(list1);
                for (GameAttribute gameAttribute1 : list1) {
                    String fieldName = gameAttribute1.getSystemKey();
                    gameAttribute.setSystemKey(fieldName + "group");
                    gameAttribute1.setUuid(UUIDGenerator.generateUuid6());
                    List<GameAttribute> listGroup = gameAttributeService.keySelectGameAttributeList(gameAttribute);
                    if (CollectionUtils.isNotEmpty(listGroup)) {
                        gameAttribute1.setChildGameAttributes(listGroup);
                        for (GameAttribute gameAttribute2 : listGroup) {
                            gameAttribute2.setUuid(UUIDGenerator.generateUuid6());

                            GameAttribute serverAttr = new GameAttribute();
                            serverAttr.setParentId(gameAttribute2.getId());
                            serverAttr.setGameId(gameId);
                            List<GameAttribute> serverList = gameAttributeService.selectGameAttributeList(serverAttr);
                            gameAttribute2.setChildGameAttributes(serverList);
                            for (GameAttribute gameAttribute3 : serverList) {
                                gameAttribute3.setUuid(UUIDGenerator.generateUuid6());
                            }
                        }
                    }

                }
            }
            return list;
        } else if (gameInfo.getType() == 1) {
            GameAttribute gameAttribute = new GameAttribute();
            gameAttribute.setGameId(gameId);
            gameAttribute.setSystemKey("group");
            List<GameAttribute> list = gameAttributeService.keySelectGameAttributeList(gameAttribute);
            if (CollectionUtils.isNotEmpty(list)) {
                for (GameAttribute attribute : list) {
                    attribute.setUuid(UUIDGenerator.generateUuid6());

                    if (attribute.getParentId() > 0) {
                        GameAttribute attribute1 = new GameAttribute();
                        attribute1.setParentId(attribute.getId());

                        List<GameAttribute> list1 = gameAttributeService.selectGameAttributeList(attribute1);
                        if (CollectionUtils.isNotEmpty(list1)) {
                            for (GameAttribute gameAttribute1 : list1) {
                                gameAttribute1.setUuid(UUIDGenerator.generateUuid6());
                            }
                        }
                        attribute.setChildGameAttributes(list1);
                    }
                }
            }
            return list;
        } else {
            return new ArrayList<>();
        }
    }

    @Override
    public void mateGame(Map<String, Object> params) {
        String config = MapUtils.getString(params, "config");
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        Long gameId = MapUtils.getLong(params, "gameId");
        String gameName = MapUtils.getString(params, "gameName");
        if (Objects.isNull(gameId)) {
            throw new GlobalException("虞都游戏不能为空");
        }
        String interGameId = MapUtils.getString(params, "interGameId");
        String interGameName = MapUtils.getString(params, "interGameName");
        if (Objects.isNull(interGameId)) {
            throw new GlobalException("接口游戏不能为空");
        }

        InterAttr interAttr2 = interAttrMapper.selectInterAttrByConfig(config, gameId);

        InterAttr interAttr = new InterAttr();
        interAttr.setCreateTime(new Date());
        interAttr.setConfigId(config);
        interAttr.setYdGameId(gameId);
        interAttr.setYdGameName(gameName);
        interAttr.setInterGameId(interGameId);
        interAttr.setInterGameName(interGameName);

        if (Objects.isNull(interAttr2)) {
            interAttrMapper.insertInterAttr(interAttr);
        } else {
            BeanUtils.copyProperties(interAttr, interAttr2);
            interAttrMapper.updateInterAttr(interAttr2);
        }
    }

    @Override
    public void mateServe(JSONObject object) {


        String config = object.getString("config");
        Long ydGameId = object.getLong("ydGameId");
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        if (Objects.isNull(ydGameId)) {
            throw new GlobalException("游戏不能为空");
        }

        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(config, ydGameId);
        if (Objects.isNull(interAttr)) {
            throw new GlobalException("接口未查询到、请检查是否已配置游戏");
        }


        object.put("ydGameName", interAttr.getYdGameName());
        object.put("interGameId", interAttr.getInterGameId());
        object.put("interServeReqs", object.getJSONArray("interServeReqs"));
        interAttr.setServer(object.toJSONString());
        interAttrMapper.updateInterAttr(interAttr);
    }

    @Override
    public void mateRadio(JSONObject object) {

        String config = object.getString("config");
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        Long yuduId = object.getLong("ydGameId");
        if (Objects.isNull(yuduId)) {
            throw new GlobalException("虞都游戏ID不能为空");
        }

        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(config, yuduId);
        if (Objects.isNull(interAttr)) {
            throw new GlobalException("接口未查询到、请检查是否已匹配游戏");
        }
        String server = interAttr.getServer();
        if (StringUtils.isEmpty(server)) {
            throw new GlobalException("请检查是否已匹配区服");
        }

        object.put("ydGameId", interAttr.getYdGameId());
        object.put("ydGameName", interAttr.getYdGameName());

        object.put("interGameId", interAttr.getInterGameId());
        object.put("interGameName", interAttr.getInterGameName());
        object.put("interRadioReqs", object.getJSONArray("interRadioReqs"));

        interAttr.setRadioAttr(object.toJSONString());
        interAttrMapper.updateInterAttr(interAttr);
    }


    @Override
    public void mateCheckBox(JSONObject object) {

        String config = object.getString("config");
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }

        Long yuduId = object.getLong("ydGameId");
        if (Objects.isNull(yuduId)) {
            throw new GlobalException("虞都游戏ID不能为空");
        }


        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(config, yuduId);
        if (Objects.isNull(interAttr)) {
            throw new GlobalException("接口未查询到、请检查是否已匹配游戏");
        }
        String server = interAttr.getServer();
        if (StringUtils.isEmpty(server)) {
            throw new GlobalException("请检查区服是否已匹配");
        }

        String radioAttr = interAttr.getRadioAttr();
        if (StringUtils.isEmpty(radioAttr)) {
            throw new GlobalException("请检查单选项是否已匹配");
        }

        object.put("ydGameId", interAttr.getYdGameId());
        object.put("ydGameName", interAttr.getYdGameName());

        object.put("interGameId", interAttr.getInterGameId());
        object.put("interGameName", interAttr.getInterGameName());
        object.put("interCheckBoxReqs", object.getJSONArray("interCheckBoxReqs"));

        interAttr.setCheckAttr(object.toJSONString());
        interAttrMapper.updateInterAttr(interAttr);
    }

    @Override
    public void mateInput(InterInputReq interInputReq) {

        String config = interInputReq.getConfig();
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        Long yuduId = interInputReq.getYdGameId();
        if (Objects.isNull(yuduId)) {
            throw new GlobalException("虞都游戏ID不能为空");
        }

        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(config, yuduId);
        if (Objects.isNull(interAttr)) {
            throw new GlobalException("接口未查询到、请检查是否已匹配游戏");
        }
        String server = interAttr.getServer();
        if (StringUtils.isEmpty(server)) {
            throw new GlobalException("请检查区服是否已匹配");
        }

        String radioAttr = interAttr.getRadioAttr();
        if (StringUtils.isEmpty(radioAttr)) {
            throw new GlobalException("请检查单选项是否已匹配");
        }

        String checkAttr = interAttr.getCheckAttr();
        if (StringUtils.isEmpty(checkAttr)) {
            throw new GlobalException("请检查多选项是否已匹配");
        }

        String jsonInput = JSON.toJSONString(interInputReq);
        interAttr.setInputAttr(jsonInput);
        interAttrMapper.updateInterAttr(interAttr);
    }

    @Override
    public void mateOther(JSONObject object) {

        String config = object.getString("config");
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        Long yuduId = object.getLong("ydGameId");
        if (Objects.isNull(yuduId)) {
            throw new GlobalException("虞都游戏ID不能为空");
        }

        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(config, yuduId);
        if (Objects.isNull(interAttr)) {
            GameInfo gameInfo = gameInfoMapper.selectGameInfoById(yuduId);
            interAttr = new InterAttr();
            interAttr.setConfigId(config);
            interAttr.setYdGameId(yuduId);
            interAttr.setYdGameName(gameInfo.getName());

            interAttr.setInterGameId(object.getString("interGameId"));
            interAttr.setInterGameName(object.getString("interGameName"));

            interAttr.setCreateTime(new Date());
            interAttrMapper.insertInterAttr(interAttr);
        }
        JSONArray reqs = object.getJSONArray("interCheckBoxReqs");
        object.put("interCheckBoxReqs",reqs);
        String other = JSON.toJSONString(object);
        interAttr.setCheckOther(other);
        interAttrMapper.updateInterAttr(interAttr);
    }

    @Override
    public void updateInterAttr(InterAttr interAttr) {
        interAttrMapper.updateInterAttr(interAttr);
    }

    @Override
    public JSONObject selectInfoByConfigIdAndGameId(Long gameId, String config, String type) {
        if (Objects.isNull(config)) {
            throw new GlobalException("接口不能为空");
        }
        if (Objects.isNull(gameId)) {
            throw new GlobalException("虞都游戏ID不能为空");
        }
        JSONObject result = new JSONObject();
        InterAttr interAttr = interAttrMapper.selectInterAttrByConfig(config, gameId);
        if (Objects.nonNull(interAttr)) {
            if (StringUtils.isEmpty(type)) {
                result = JSONObject.parseObject(JSONObject.toJSONString(interAttr));
                result.put("server", JSONObject.parseObject(result.getString("server")));
                result.put("checkAttr", JSONObject.parseObject(result.getString("checkAttr")));
                result.put("radioAttr", JSONObject.parseObject(result.getString("radioAttr")));
                result.put("inputAttr", JSONObject.parseObject(result.getString("inputAttr")));
                result.put("checkOther", JSONObject.parseObject(result.getString("checkOther")));
            } else if (StringUtils.equals(type, "server")) {
                result = JSONObject.parseObject(JSONObject.toJSONString(interAttr.getServer()));
            } else if (StringUtils.equals(type, "checkAttr")) {
                result = JSONObject.parseObject(JSONObject.toJSONString(interAttr.getCheckAttr()));
            } else if (StringUtils.equals(type, "radioAttr")) {
                result = JSONObject.parseObject(JSONObject.toJSONString(interAttr.getRadioAttr()));
            } else if (StringUtils.equals(type, "inputAttr")) {
                result = JSONObject.parseObject(JSONObject.toJSONString(interAttr.getInputAttr()));
            } else if (StringUtils.equals(type, "checkOther")) {
                result = JSONObject.parseObject(JSONObject.toJSONString(interAttr.getCheckOther()));
            }
        }
        return result;
    }

}
